package com.tiyo.system.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tiyo.common.core.domain.AjaxResult;
import com.tiyo.common.core.domain.Ztree;
import com.tiyo.framework.web.controller.BaseController;
import com.tiyo.system.mapper.domain.SysDept;
import com.tiyo.system.service.DeptService;
/**
 * 
 * @Description 机构管理
 * @author yangb
 * @version v1.0
 * @date 2021年1月21日
*
 */
@RequestMapping("/system/dept")
@Controller
public class SysDeptController extends BaseController {
	private String prefix = "system/dept";
	@GetMapping()
	public String dept() {
		return prefix + "/dept";
	}
	@Autowired
    private DeptService deptService;
	  /**
     * 加载部门列表树
     */
    @GetMapping("/treeData")
    @ResponseBody
    public List<Ztree> treeData()
    {
        List<Ztree> ztrees = deptService.selectDeptTree(new SysDept());
        return ztrees;
    }
    @PostMapping("/list")
    @ResponseBody
    public AjaxResult list(SysDept dept)
    {
        return AjaxResult.success(deptService.page(dept));
    }
    @PostMapping("/listChild")
    @ResponseBody
    public List<SysDept> listChild(SysDept dept)
    {
    	return deptService.list(dept);
    }
}
